home *** CD-ROM | disk | FTP | other *** search
-
- Notes for Shell writters...
-
- *****************************************************
- If you write a tools that use or change Worbench PathList, please use
- this very simple mechanism because no other locking is possible. This is
- the only security aviable.
- See below.
- *****************************************************
-
- I write this library because I think some notifications' mechanisms are
- missing in AmigaDos. For exemple: You can't be notified when an other
- task change assign. More, some resources, like Workench path can't be
- locked.
-
- If you program your shell in a Registery.library compatible ways,
- others tasks, like system's monitors, may be notified when you change
- something... You can declare others resources as you need (eg: for
- custom IO/ports, IRControler, your coffee machine ...) and this library
- provide a simple but powerfull locking mechanisme.
-
- Following resources are defined to monitor some standard systeme datas:
-
- Assign :
- ~~~~~~~~
- All is automaticly done by AssignPatch (included in this distribution).
- As Dos's functions AssignAdd(), AssignLate(), AssignLock(), AssignPath()
- and RemAssignList() are patched, all changes made are notified.
-
- In the system's monitor side, the resource is named "ASSIGN".
- Note: Don't try to lock this resource because locked "ASSIGN" resource
- means AssignPatch is running... The right way is to use the standard dos'
- LockDosList() function. On the other hand, you may temporaly disable
- notifications -RL_DisableNotifying()- if you make many changes at a
- time.
-
- See TestNotify.c for an example source code for looking for notification.
- If you change RL_RegisterClass("TST_RES_NOTIF") to "ASSIGN", TestNotify
- is notified for all assign opération.
-
-
- EnvVariables :
- ~~~~~~~~~~~~~~
- Like Assign, all is done by AssignPatch ( SetVar() and DeleteVar() are
- patched and a dos notification is used to monitor direct file change in
- ENV: - i.e: Use file functions for changing a variable).
-
- The resource name is "ENVVAR". Like for Assign, locking this resouce
- doesn't do nothing.
-
-
- Residents:
- ~~~~~~~~~~
- AssignPatch patch dos' AddSegment() and RemSegment() so adding or removing
- a resident cause automaticaly notifications.
-
- The resouce name is "RESIDENT" and only a Forbid()/Permit() pair allow a
- protection when you read this list, as all semaphore in dos structure are
- private... Locking this resouce does nothing!
-
-
- Path:
- ~~~~~
- Normaly, only CLI processes may access to there own Path list, so no
- semaphore exist. But, the Workbench's one is concidered as "the global
- path", because all others CLI may start from it. For tools that may
- modifying this resource, registery.library permit a "better than nothing"
- arbitration.
-
- The resource name is "WB_PATH".
- Notes:
- * ListRegistry does't display this resource if nobody use it - this
- resource is totaly free in this case -.
- * I know very few program that are working on WB PathList (CSH and
- my very own LFSystemBinder).
-
- This example show how to use registry.library with a custom PATH command.
- It's come from csh 5.40 source code, only "path -r[g]" section: remove an
- existing path...
-
-
- . . .
-
- if ( options&1 ) { // Option -r : Remove
- long noram = 0;
- --- « NEW »
- || APTR wbpathres;
- ||
- || if ( options&2 && RegistryBase ) {
- || // Option -g : For all running CLI and if registry.library
- || // could be openned.
- || wbpathres = RL_RegisterResource("WB_PATH"); //register the resource
- || if(!RL_LockResource(wbpathres,FALSE)){ // Try an exclusif lock
- || RL_UnRegisterResource(wbpathres);
- || ierror("Workbench PathList", ERROR_OBJECT_IN_USE);
- || // Internal CSH func for printing an error message
- || return 20;
- || }
- || }
- -----
-
- Forbid(); // No other task may modif path-list
- mincli = 1;
-
- . . . ««« CSH stuff for erasing path »»» . . .
-
- Permit();
-
- ---- « NEW »
- || if ( options&2 && RegistryBase ) { // Some cleanup
- || RL_UnLockResource(wbpathres);
- || RL_Notify(wbpathres); // Hey, something have changed!
- || RL_UnRegisterResource(wbpathres);
- || }
- -----
-
- if (noram>0) {
-
- . . .
-
- Somes notes:
- - options&2 means we want to change ALL paths (including WBPath) else
- only our own path is changed - so no arbitration is needed as we are not
- the Workbench !-.
- - If "WB_PATH" resource can't be locked means another process use
- this resource -> We *must* fail or we trash this process datas!
- - We *must* notify ourself -RL_Notify()- for resource's modifications.
-
-
-
- CSH is (c) 1986 Matt. Dillon,
- versions 5.20+ OS 2.0 versions by A. Kirchwitz, M. Berndt
-